
/* GENERATED CODE:
 *  Any modifications you make are guaranteed
 *  to be deleted when this is regenerated.
 * Please edit "PROTOCOLS" inside this directory
 *
 * Names are all upper case because of "String" and "string."
 */

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using OWED.Network.Messages.General;
using OWED.Network.Messages;
using OWED.Network.Messages.Reply;


namespace OWED.Network.Messages.General
{
	public class Date: IProtocolItem 
	{
		int my_year;
		int my_month;
		int my_day;
		int my_hour;
		int my_minute;
		int my_second;
		public Date (int year, int month, int day, int hour, int minute, int second)
		{
			my_year = year;
			my_month = month;
			my_day = day;
			my_hour = hour;
			my_minute = minute;
			my_second = second;
		}
		public int year { get { return my_year; } }
		public int month { get { return my_month; } }
		public int day { get { return my_day; } }
		public int hour { get { return my_hour; } }
		public int minute { get { return my_minute; } }
		public int second { get { return my_second; } }


		public static new Date FromXml(XmlDocument xml)
		{
			int year = int.Parse(xml.SelectSingleNode("Date").Attributes.GetNamedItem("year").Value);
			int month = int.Parse(xml.SelectSingleNode("Date").Attributes.GetNamedItem("month").Value);
			int day = int.Parse(xml.SelectSingleNode("Date").Attributes.GetNamedItem("day").Value);
			int hour = int.Parse(xml.SelectSingleNode("Date").Attributes.GetNamedItem("hour").Value);
			int minute = int.Parse(xml.SelectSingleNode("Date").Attributes.GetNamedItem("minute").Value);
			int second = int.Parse(xml.SelectSingleNode("Date").Attributes.GetNamedItem("second").Value);
			return new Date(year, month, day, hour, minute, second);
		}


		public override XmlDocument ToXml()		{
			XmlDocument doc = new XmlDocument();

			doc.AppendChild(doc.CreateElement("Date"));
			XmlAttribute attr;
			attr = doc.CreateAttribute("year");
			attr.Value = my_year.ToString();
			doc.FirstChild.Attributes.Append(attr);

			attr = doc.CreateAttribute("month");
			attr.Value = my_month.ToString();
			doc.FirstChild.Attributes.Append(attr);

			attr = doc.CreateAttribute("day");
			attr.Value = my_day.ToString();
			doc.FirstChild.Attributes.Append(attr);

			attr = doc.CreateAttribute("hour");
			attr.Value = my_hour.ToString();
			doc.FirstChild.Attributes.Append(attr);

			attr = doc.CreateAttribute("minute");
			attr.Value = my_minute.ToString();
			doc.FirstChild.Attributes.Append(attr);

			attr = doc.CreateAttribute("second");
			attr.Value = my_second.ToString();
			doc.FirstChild.Attributes.Append(attr);


			return doc;
		}
	}
}
